﻿@model CuongHanh.Models.MyStyle
@(Html.X()
          .FormPanel()
          .Region(Region.Center)
          .Border(false)
          .StyleSpec("background-color:white;")
          .Padding(10)
          .Items(form =>
                 {
                     form.Add(Html.X().HiddenFor(m => m.Id));
                     form.Add(Html.X()
                             .TextFieldFor(m => m.Code)
                             .FieldLabel("Mã")
                             .Width(500)
                             );
                     form.Add(Html.X()
                            .TextFieldFor(m => m.Name)
                            .FieldLabel("Tên T.Việt")
                            .Width(500)
                            );
                     form.Add(Html.X()
                             .TextFieldFor(m => m.NameEn)
                             .FieldLabel("Tên T.Anh")
                             .Width(500)
                             );
                     form.Add(Html.X()
                            .ComboBoxFor(m => m.ParentId)
                            .FieldLabel("Mẫu cha")
                            .Width(500)
                            .ForceSelection(true)
                            .DisplayField("Name")
                            .ValueField("Id")
                            .EmptyText("Mẫu cha")
                            .Store(Html.X().Store()
                                    .AutoLoad(true)
                                    .Model(Html.X().Model()
                                            .IDProperty("Id")
                                            .Fields(
                                                    "Id",
                                                    "Name"
                                            )
                                    )
                                    .Proxy(Html.X().AjaxProxy()
                                            .Json(true)
                                            .Url(Url.Action("GetStylesCombo"))
                                            .ActionMethods(v => v.Read = HttpMethod.POST)
                                            .Reader(Html.X().JsonReader().Root("data").TotalProperty("total"))
                                    )
                                    .Listeners(ls =>
                                            ls.Load.Handler = "App.ParentId.setValue(" + Model.ParentId + ");"
                                    )
                            ));
                     form.Add(Html.X()
                           .ComboBoxFor(m => m.StyleTypeId)
                           .FieldLabel("Loại")
                           .Width(500)
                           .ForceSelection(true)
                           .DisplayField("Name")
                           .ValueField("Id")
                           .EmptyText("Loại")
                           .Store(Html.X().Store()
                                   .AutoLoad(true)
                                   .Model(Html.X().Model()
                                           .IDProperty("Id")
                                           .Fields(
                                                   "Id",
                                                   "Name"
                                           )
                                   )
                                   .Proxy(Html.X().AjaxProxy()
                                           .Json(true)
                                           .Url(Url.Action("GetStyleTypesCombo"))
                                           .ActionMethods(v => v.Read = HttpMethod.POST)
                                           .Reader(Html.X().JsonReader().Root("data").TotalProperty("total"))
                                   )
                                   .Listeners(ls =>
                                           ls.Load.Handler = "App.StyleTypeId.setValue(" + Model.StyleTypeId + ");"
                                   )
                           ));
                     form.Add(Html.X().FileUploadField()
                            .ID("FileUploadField1")
                            .FieldLabel("Hình ảnh")
                            .Width(500)
                            .EmptyText("chọn file ảnh upload")
                            .ButtonText("")
                            .Icon(Icon.ImageAdd));
                     form.Add(Html.X()
                             .Button()
                             .ID("btUpdate")
                             .Text("Lưu lại")
                             .FormBind(true)
                             .StyleSpec("margin-left:105px;")
                             .DirectClickAction("Edit")
                             );
                     form.Add(Html.X()
                             .Button()
                             .ID("btCancel")
                             .Text("Hủy")
                             .StyleSpec("margin-left:10px;")
                             .OnClientClick("App.wdModify.hide();")
                             );
                 }))